import instance from './index';
import qs from 'qs';

const preUrlPath = '';
//获取市场列表-分页
const request = {
  p: ['api:user:fetch'],
  r: params => {
    return instance.get(`/v1/market/fetchPageList`, {params}).catch(function(res){
      console.log(res)
    })
  }
};
//获取市场列表-通过币种获取
const requestMarket = {
  p: ['api:user:fetch'],
  r: params => {
    return instance.get(`/v1/market/fetchMarketListByCoinId`, {params}).catch(function(res){
      console.log(res)
    })
  }
};
//设置市场状态
const modifyStatus = {
  p: ['api:user:fetch'],
  r: params => {
    return instance.post(`/v1/market/setMarketStatus`, qs.stringify(params),{ headers:{'Content-Type':'application/x-www-form-urlencoded'}}).catch(function(res){
      console.log(res)
    })
  }
};
//添加市场
const add = {
  p: ['api:user:new'],
  r: params => {
    return instance.post(`/v1/market/new`, qs.stringify(params),{ headers:{'Content-Type':'application/x-www-form-urlencoded'}}).catch(function(res){
      console.log(res)
    })
  }
};
//获取市场信息
const info = {
  p: ['get'],
  r: params => {
    return instance.get(`/v1/market/info`, {params}).catch(function(res){
      console.log(res)
    })
  }
};
//获取交易区域列表
const listArea = {
  p: ['get'],
  r: params => {
    return instance.get(`/v1/sys/fetchTransAreaList`, {params}).catch(function(res){
      console.log(res)
    })
  }
};
//获取交易区列表--系统业务配置列表
const areaList = {
  p: ['get'],
  r: params => {
    return instance.get(`/v1/cfg/fetchConfigList`, {params}).catch(function(res){
      console.log(res)
    })
  }
};

//编辑用户
const modify = {
  p: ['api:user:modify'],
  r: params => {
    return instance.post(`/v1/market/modify`, qs.stringify(params),{ headers:{'Content-Type':'application/x-www-form-urlencoded'}}).catch(function(res){
      console.log(res)
    })
  }
};

//越权请求
const notAllowed = {
  p: ['get,/roles/notAllowed'],
  r: params => {
    return instance.get(`${preUrlPath}/GET/roles/notAllowed`, {params})
  }
}

export {
  request,
  notAllowed,
  add,
  modify,
  info,
  modifyStatus,
  listArea,
  requestMarket,
}
